// 设置cookie
function setCookie(cname, cvalue, exdays) {
  let d = new Date();
  d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
  let expires = `expires=${d.toGMTString()}`;
  document.cookie = `${cname}=${cvalue}; ${expires}`;
}

// 获取cookie
function getCookie(cname) {
  let name = `${cname}=`;
  let ca = document.cookie.split(" ;");
  for (let i = 0; i < ca.length; i++) {
    if (ca[i].indexOf(name) === 0) {
      return ca[i].substring(name.length);
    }
  }
  return "";
}

// 检查是否有cookie
function checkCookie(cname) {
  let cvalue = getCookie(cname);
  if (cvalue) {
    return true;
  } else {
    return false;
  }
}
